﻿using System;

namespace SsisLdapSource
{
    using System.Linq;

    using global::SsisLdapSource.DirectoryServicesProtocolsExtensions;

    public partial class SsisLdapSource : ILdapSearchRequestPropertiesContainer
    {
        public string SearchFilter
        {
            get
            {
                return (string)ComponentMetaData.CustomPropertyCollection["SearchFilter"].Value;
            }
            set { throw new NotImplementedException(); }
        }

        public string SearchBaseDN
        {
            get
            {
                return (string)ComponentMetaData.CustomPropertyCollection["BaseDN"].Value;
            }
            set { throw new NotImplementedException(); }
        }

        public string[] AttributesToLoad
        {
            get
            {
                var attributesToLoad = (string[])ComponentMetaData.CustomPropertyCollection["AttributesToLoad"].Value;
                if (!attributesToLoad.Contains(UniqueObjectIdentifierAttribute, StringComparer.OrdinalIgnoreCase))
                {
                    Array.Resize(ref attributesToLoad, attributesToLoad.Length + 1);
                    attributesToLoad[attributesToLoad.Length - 1] = UniqueObjectIdentifierAttribute;
                }

                return attributesToLoad;
            }
            set { throw new NotImplementedException(); }
        }

        public int PageSize
        {
            get
            {
                return (int)ComponentMetaData.CustomPropertyCollection["PageSize"].Value;
            } 
        }

        public string UniqueObjectIdentifierAttribute
        {
            get
            {
                return ComponentMetaData.CustomPropertyCollection["LdapPrimaryKeyEquivalent"].Value.ToString();
            }
            set { throw new NotImplementedException(); }
        }

        public bool IncludeObjectOwnerInfo
        {
            get
            {
                return (bool)ComponentMetaData.CustomPropertyCollection["IncludeObjectOwnerInfo"].Value;
            }
            set{throw new NotImplementedException();}

        }

        public bool IsDomainScopeEnforced
        {
            get
            {
                return (bool)ComponentMetaData.CustomPropertyCollection["DomainScopeEnforced"].Value;
            }
            set {throw new NotImplementedException();}
        }

        private PagedSearchRequest PagedSearchRequest
        {
            get
            {
                return new PagedSearchRequest(this);
            }
        }
    }
}
